#include <stdio.h>
#include <stdlib.h>

struct _node{
              int data;
    struct _node *next;   
};
struct _node* generate_node(struct _node *,int);
struct _node* generate_node(struct _node *p,int num)
{
    p = (struct _node *)malloc(sizeof(struct _node)); 
    p->data = num;
    p->next = NULL;
    return p;
}
int main(void)
{	
    int i;	
    struct _node *a,*b,*c,*d,*e; 	
    generate_node(a,1);	
    generate_node(b,2);	
    generate_node(c,5);	
    generate_node(d,7);	
    generate_node(e,9);	
    b = next;	
    c = b;	
    d = c;  	
    e = d;  
    
    struct _node * q = (struct _node *)malloc(sizeof(struct _node)); 

    for(q = a;q->next !=NULL;)
    {
    	    q = q->next;    
    }   
    printf("q->data=%d",q->data);    
    struct _node * r = (struct _node *)malloc(sizeof(struct _node));
    struct _node * v = (struct _node *)malloc(sizeof(struct _node));
    struct _node * y = (struct _node *)malloc(sizeof(struct _node));
    q == a;
    for(i =0;i < 2;i++)  //serlect
    {
       q = q->next;    
    }
       q->next = r;
       r = q;
    for (i =0;i <2;i++)
    {
       v = v->next;     
    }	
       y = v->next; 
       v->next->next = v;
       free(y);
      return 0;
}
	
